﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ReactiveLang.Collections
{
    using Util;

    partial class EnumerableExpression
    {
        internal class Subject<T> : SubjectBase<IEnumerableExpressionParent<T>>, IEnumerableExpression<T>, IEnumerableExpressionParent<T>
        {
            public IDisposable OnItem(IExpression<T> item, int index)
            {
                return Parents.Select(p => p.OnItem(item, index)).Concat();
            }

            public void OnValue(Unit value)
            {
                ForEach(p => p.OnValue(value));
            }

            public void OnException(Exception ex)
            {
                ForEach(p => p.OnException(ex));
            }
        }
    }
}